<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateExchangeCodeTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('exchange_code', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('code')->comment('code');
            $table->integer('user_id')->nullable(true)->comment('领取用户id');
            $table->tinyInteger('status')->default(0)->comment('状态 0-未领取 1-已领取 2-已使用');
            $table->integer('coupon_id')->comment('优惠券id');
            $table->string('order_id')->nullable(true)->comment('订单id');
            $table->timestamp('receive_time')->nullable()->comment('领取时间');
            $table->timestamp('consume_time')->nullable()->comment('使用时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('exchange_code');
    }
}
